package mt.dummy;

import javax.swing.JOptionPane;

import mt.comm.ClientMessage;
import mt.comm.ClientSideMessage;

public class Redicite extends Thread{
	private ClientCommDummy ccd;

	public Redicite(ClientCommDummy clientCommDummy) {
		this.ccd=clientCommDummy;
	}
	
	@Override
	public void run() {
		while(!interrupted()){
			if(ccd.hasNextMessage()){
				System.out.println("gayyyyyyyy");
				ClientMessage m = ccd.getNextMessage();
				if(m.getType().equals(ClientSideMessage.Type.ERROR)){
					JOptionPane.showMessageDialog(null, "Name is already in use");
					ccd.disconnect();
					System.exit(1);
				}
			}
		}
	}
}
